# This file is part of BlackArch Linux ( https://www.blackarch.org/ ).
# See COPYING for license details.

pkgname=wesng
pkgver=440.c363505
pkgrel=1
pkgdesc='Windows Exploit Suggester - Next Generation.'
arch=('any')
groups=('blackarch' 'blackarch-exploitation' 'blackarch-windows')
url='https://github.com/bitsadmin/wesng'
license=('BSD')
depends=('python' 'python-argparse' 'python-chardet')
makedepends=('git')
source=("git+https://github.com/bitsadmin/wesng.git")
sha512sums=('SKIP')

pkgver() {
  cd $pkgname

  ( set -o pipefail
    git describe --long --tags --abbrev=7 2>/dev/null |
      sed 's/\([^-]*-g\)/r\1/;s/-/./g' ||
    printf "%s.%s" "$(git rev-list --count HEAD)" \
      "$(git rev-parse --short=7 HEAD)"
  )
}

package() {
  cd $pkgname

  install -dm 755 "$pkgdir/usr/bin"

  install -Dm 755 -t "$pkgdir/usr/share/$pkgname" *.py
  install -Dm 644 -t "$pkgdir/usr/share/doc/$pkgname" README.md CHANGELOG.md
  install -Dm 644 LICENSE.txt "$pkgdir/usr/share/licenses/$pkgname/LICENSE"

  cp -a --no-preserve=ownership collector/ validation/ *.zip \
    "$pkgdir/usr/share/$pkgname/"

  cat > "$pkgdir/usr/bin/$pkgname" << EOF
#!/bin/sh
cd /usr/share/$pkgname
exec python3 wes.py "\$@"
EOF

  chmod +x "$pkgdir/usr/bin/$pkgname"
}

